﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Globalization;
using System.Threading;

namespace Century.Web.UI.MVC
{
    public class SitePathHandlerController : DefaultControllerFactory
    {

        protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType)
        {
            //return base.GetControllerInstance(requestContext, controllerType);
            //Get the {langCode} parameter in the RouteData
            
            if (requestContext.RouteData.Values["stPath"] == null)
            {
                return base.GetControllerInstance(requestContext, controllerType);
            }
            string sitePath = requestContext.RouteData.Values["stPath"].ToString();

            if (sitePath == null)
            {
                requestContext.RouteData.Values["stPath"] = sitePath = "en";
            }
          
            return base.GetControllerInstance(requestContext, controllerType);
        }

    }
}
